package com.zx.BookSeaReader.greendao.entity;



import androidx.annotation.Nullable;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.JoinEntity;
import org.greenrobot.greendao.annotation.ToMany;
import org.greenrobot.greendao.annotation.Transient;

import java.io.Serializable;
import java.util.List;
import org.greenrobot.greendao.DaoException;
import com.zx.BookSeaReader.greendao.gen.DaoSession;
import com.zx.BookSeaReader.greendao.gen.UserBeanDao;
import com.zx.BookSeaReader.greendao.gen.BookDao;
import com.zx.BookSeaReader.greendao.gen.BookListBeanDao;

/**
 * @Author: ZX
 * @Time: 2020/2/15
 * @Description: 书
 */
@Entity
public class Book implements Serializable {
    @Transient
    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    private String name;//书名
    private String chapterUrl;//书目Url
    private String imgUrl;//封面图片url
    private String desc;//简介
    private String author;//作者
    @Nullable
    private String type;//类型

    private String updateDate;//更新时间
    @Nullable
    private String newestChapterId;//最新章节id
    @Nullable
    private String newestChapterTitle;//最新章节标题
    @Nullable
    private String newestChapterUrl;//最新章节url
    @Nullable
    private String historyChapterId;//上次关闭时的章节ID
    @Nullable
    private int histtoryChapterNum;//上次关闭时的章节数

    private int sortCode;//排序编码

    private int noReadNum;//未读章数量

    private int chapterTotalNum;//总章节数

    private int lastReadPosition;//上次阅读到的章节的位置


    @Nullable
    private String source;
    @Nullable
    private String lastRead;//最后阅读时间
    //是否是本地文件
    @Nullable
    private boolean isLocal = false;

    @Nullable
    private int recommend=0;//是否是推荐书籍 1是
    @Nullable
    private boolean isCollect = false;

    @ToMany
    @JoinEntity(
            entity = SubscribeBean.class,
            sourceProperty = "bookid",
            targetProperty = "userid"
    )
    private List<UserBean> users;

    @ToMany
    @JoinEntity(
            entity = BookListCollect.class,
            sourceProperty = "bookid",
            targetProperty = "bookListid"
    )
    private List<BookListBean> bookLists;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 1097957864)
    private transient BookDao myDao;


    @Generated(hash = 2099595037)
    public Book(String id, String name, String chapterUrl, String imgUrl, String desc, String author,
            String type, String updateDate, String newestChapterId, String newestChapterTitle,
            String newestChapterUrl, String historyChapterId, int histtoryChapterNum, int sortCode,
            int noReadNum, int chapterTotalNum, int lastReadPosition, String source, String lastRead,
            boolean isLocal, int recommend, boolean isCollect) {
        this.id = id;
        this.name = name;
        this.chapterUrl = chapterUrl;
        this.imgUrl = imgUrl;
        this.desc = desc;
        this.author = author;
        this.type = type;
        this.updateDate = updateDate;
        this.newestChapterId = newestChapterId;
        this.newestChapterTitle = newestChapterTitle;
        this.newestChapterUrl = newestChapterUrl;
        this.historyChapterId = historyChapterId;
        this.histtoryChapterNum = histtoryChapterNum;
        this.sortCode = sortCode;
        this.noReadNum = noReadNum;
        this.chapterTotalNum = chapterTotalNum;
        this.lastReadPosition = lastReadPosition;
        this.source = source;
        this.lastRead = lastRead;
        this.isLocal = isLocal;
        this.recommend = recommend;
        this.isCollect = isCollect;
    }
    @Generated(hash = 1839243756)
    public Book() {
    }
    public String getId() {
        return this.id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getChapterUrl() {
        return this.chapterUrl;
    }
    public void setChapterUrl(String chapterUrl) {
        this.chapterUrl = chapterUrl;
    }
    public String getImgUrl() {
        return this.imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
    public String getDesc() {
        return this.desc;
    }
    public void setDesc(String desc) {
        this.desc = desc;
    }
    public String getAuthor() {
        return this.author;
    }
    public void setAuthor(String author) {
        this.author = author;
    }
    public String getType() {
        return this.type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getUpdateDate() {
        return this.updateDate;
    }
    public void setUpdateDate(String updateDate) {
        this.updateDate = updateDate;
    }
    public String getNewestChapterId() {
        return this.newestChapterId;
    }
    public void setNewestChapterId(String newestChapterId) {
        this.newestChapterId = newestChapterId;
    }
    public String getNewestChapterTitle() {
        return this.newestChapterTitle;
    }
    public void setNewestChapterTitle(String newestChapterTitle) {
        this.newestChapterTitle = newestChapterTitle;
    }
    public String getNewestChapterUrl() {
        return this.newestChapterUrl;
    }
    public void setNewestChapterUrl(String newestChapterUrl) {
        this.newestChapterUrl = newestChapterUrl;
    }
    public String getHistoryChapterId() {
        return this.historyChapterId;
    }
    public void setHistoryChapterId(String historyChapterId) {
        this.historyChapterId = historyChapterId;
    }
    public int getHisttoryChapterNum() {
        return this.histtoryChapterNum;
    }
    public void setHisttoryChapterNum(int histtoryChapterNum) {
        this.histtoryChapterNum = histtoryChapterNum;
    }
    public int getSortCode() {
        return this.sortCode;
    }
    public void setSortCode(int sortCode) {
        this.sortCode = sortCode;
    }
    public int getNoReadNum() {
        return this.noReadNum;
    }
    public void setNoReadNum(int noReadNum) {
        this.noReadNum = noReadNum;
    }
    public int getChapterTotalNum() {
        return this.chapterTotalNum;
    }
    public void setChapterTotalNum(int chapterTotalNum) {
        this.chapterTotalNum = chapterTotalNum;
    }
    public int getLastReadPosition() {
        return this.lastReadPosition;
    }
    public void setLastReadPosition(int lastReadPosition) {
        this.lastReadPosition = lastReadPosition;
    }
    public String getSource() {
        return this.source;
    }
    public void setSource(String source) {
        this.source = source;
    }
    public String getLastRead() {
        return this.lastRead;
    }
    public void setLastRead(String lastRead) {
        this.lastRead = lastRead;
    }
    public boolean getIsLocal() {
        return this.isLocal;
    }
    public void setIsLocal(boolean isLocal) {
        this.isLocal = isLocal;
    }
    public int getRecommend() {
        return this.recommend;
    }
    public void setRecommend(int recommend) {
        this.recommend = recommend;
    }
    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 1757164237)
    public List<UserBean> getUsers() {
        if (users == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            UserBeanDao targetDao = daoSession.getUserBeanDao();
            List<UserBean> usersNew = targetDao._queryBook_Users(id);
            synchronized (this) {
                if (users == null) {
                    users = usersNew;
                }
            }
        }
        return users;
    }
    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 1027274768)
    public synchronized void resetUsers() {
        users = null;
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1115456930)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getBookDao() : null;
    }
    public boolean getIsCollect() {
        return this.isCollect;
    }
    public void setIsCollect(boolean isCollect) {
        this.isCollect = isCollect;
    }
    /**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 764625401)
    public List<BookListBean> getBookLists() {
        if (bookLists == null) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            BookListBeanDao targetDao = daoSession.getBookListBeanDao();
            List<BookListBean> bookListsNew = targetDao._queryBook_BookLists(id);
            synchronized (this) {
                if (bookLists == null) {
                    bookLists = bookListsNew;
                }
            }
        }
        return bookLists;
    }
    /** Resets a to-many relationship, making the next get call to query for a fresh result. */
    @Generated(hash = 569543232)
    public synchronized void resetBookLists() {
        bookLists = null;
    }





}
